import os;
import sys;

make = True
run = True
display_result = True
if len(sys.argv) > 1:
	if sys.argv[1] == "make":
		run = False
		display_result = False
	elif sys.argv[1] == "run":
		make = False

pwd = "/Users/yushroom/program/graphics/RayTracer"
src = pwd + "/src"
boost_path = pwd+"/3rdParty/boost_1_60_0"
subdirs = [".", "bsdfs", "materials", "math", "shapes", "utils"]
compile_cmd = "g++ "
for s in subdirs:
	compile_cmd += " ./src/" + s + "/*.cpp"
compile_cmd += " -std=c++11 -O2 -DNDEBUG -DMULTI_THREAD -o rt.out -I"+boost_path
for s in subdirs:
	compile_cmd += " -I" + src + "/" + s

if make:
	print(compile_cmd)
	#exit()
	os.system(compile_cmd)
#os.system("g++ *.cpp -std=c++11 -O2 -DNDEBUG")

if run:
	run_cmd = "time ./rt.out ./scenes/veach_mi/mi.xml"
	run_cmd = "time ./rt.out ./scenes/scene01.xml"
	#run_cmd = "time ./a.out ./scenes/scene01/scene01.xml"
	print(run_cmd)
	os.system(run_cmd)
#os.system("sips -s format png image.ppm --out image.png")

if display_result:
	show_result_cmd = "open "+pwd+"/image.bmp"
	print(show_result_cmd)
	os.system(show_result_cmd)